from manimlib import *

sys.path.append('.')
from customized import *



class p1(ThreeDScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        # self.set_camera_orientation(phi=75 * DEGREES, theta=-90 * DEGREES)
        # 1
        a, b = [-2.6, 0, 0], [-0.5, 0, 0]
        c, d = b + DL, a + DL
        s = a + UP * 1.3 + RIGHT * 0.5
        vg1 = VGroup(
            CustomizedLine(s, d), CustomizedLine(s, c), CustomizedLine(s, b),
            CustomizedLine(b, c), CustomizedLine(c, d),
            DashedLine(s, a),
            DashedLine(a, b), DashedLine(a, d)
        ).set_color(LV)
        self.add(vg1,
                 CustomizedTex('A').next_to(a, DOWN),
                 CustomizedTex('B').next_to(b),
                 CustomizedTex('C').next_to(c, DOWN),
                 CustomizedTex('D').next_to(d, DOWN),
                 CustomizedTex('S').next_to(s, UP)
                 )
        # 2
        a_, b_, c_, s_ = [3.6, -0.5, 0], [2, 0, 0], [1, -1, 0], [2.2, 1.5, 0]
        vg2 = VGroup(
            DashedLine(a_, b_), DashedLine(b_, c_), CustomizedLine(a_, c_),
            CustomizedLine(s_, a_), DashedLine(s_, b_), CustomizedLine(s_, c_)
        ).set_color(JH)
        self.add(vg2,
                 CustomizedTex(r'A^\prime').next_to(a_),
                 CustomizedTex(r'B^\prime').next_to(b_, DOWN),
                 CustomizedTex(r'C^\prime').next_to(c_, DOWN),
                 CustomizedTex(r'S^\prime').next_to(s_, UP)
                 )


class p2(ThreeDScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        # self.set_camera_orientation(phi=75 * DEGREES, theta=-90 * DEGREES)
        # 1
        a, b = [-2.6, 0, 0], [-0.5, 0, 0]
        c, d = b + DL, a + DL
        s = a + UP * 1.3 + RIGHT * 0.5
        vg1 = VGroup(
            CustomizedLine(s, d), CustomizedLine(s, c), CustomizedLine(s, b),
            CustomizedLine(b, c), CustomizedLine(c, d),
            DashedLine(s, a),
            DashedLine(a, b), DashedLine(a, d)
        ).set_color(LV)
        self.add(vg1,
                 CustomizedTex('A').next_to(a, DOWN),
                 CustomizedTex('B').next_to(b),
                 CustomizedTex('C').next_to(c, DOWN),
                 CustomizedTex('D').next_to(d, DOWN),
                 CustomizedTex('S').next_to(s, UP)
                 )
        # 2
        a_, b_, c_, s_ = [3.6, -0.5, 0], [2, 0, 0], [1, -1, 0], [2.2, 1.5, 0]
        vg2 = VGroup(
            DashedLine(a_, b_), DashedLine(b_, c_), CustomizedLine(a_, c_),
            CustomizedLine(s_, a_), DashedLine(s_, b_), CustomizedLine(s_, c_)
        ).set_color(JH)
        self.add(vg2,
                 CustomizedTex(r'A^\prime').next_to(a_),
                 CustomizedTex(r'B^\prime').next_to(b_, DOWN),
                 CustomizedTex(r'C^\prime').next_to(c_, DOWN),
                 CustomizedTex(r'S^\prime').next_to(s_, UP)
                 )
        # p2
        m = (s + b) / 2
        self.add(DashedLine(a, m).set_color(BLACK), CustomizedLine(c, m),
                 CustomizedTex('M').next_to(m, UR)
                 )
        n = (np.array(s_) + np.array(b_)) / 2
        self.add(DashedLine(a_, n).set_color(BLACK), DashedLine(c_, n).set_color(BLACK),
                 CustomizedTex('N').next_to(n, UR)
                 )


class p3(ThreeDScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        # self.set_camera_orientation(phi=75 * DEGREES, theta=-90 * DEGREES)
        # 1
        a, b = [-2.6, 0, 0], [-0.5, 0, 0]
        c, d = b + DL, a + DL
        s = a + UP * 1.3 + RIGHT * 0.5
        vg1 = VGroup(
            CustomizedLine(s, d), CustomizedLine(s, c), DashedLine(s, b),
            CustomizedLine(b, c), CustomizedLine(c, d),
            DashedLine(s, a),
            DashedLine(a, b), DashedLine(a, d)
        ).set_color(LV)
        self.add(vg1,
                 CustomizedTex('A').next_to(a, DOWN),
                 CustomizedTex(r'B(B^\prime)').next_to(b),
                 CustomizedTex(r'C(C^\prime)').next_to(c, DOWN),
                 CustomizedTex('D').next_to(d, DOWN),
                 CustomizedTex(r'S(S^\prime)').next_to(s, UP)
                 )
        # p3
        a_ = s + RIGHT * 2.1
        self.add(
            VGroup(CustomizedLine(a_, s), CustomizedLine(a_, b), CustomizedLine(a_, c)).set_color(JH),
            CustomizedTex(r'A^\prime').next_to(a_),
        )


class p4(ThreeDScene):
    # 绿色正四棱锥
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        # self.set_camera_orientation(phi=75 * DEGREES, theta=-90 * DEGREES)
        # 1
        tt=2
        a, b = [-2.6+tt, 0, 0], [-0.5+tt, 0, 0]
        c, d = b + DL, a + DL
        s = a + UP * 1.3 + RIGHT * 0.5
        vg1 = VGroup(
            CustomizedLine(s, d), CustomizedLine(s, c), CustomizedLine(s, b),
            CustomizedLine(b, c), CustomizedLine(c, d),
            DashedLine(s, a),
            DashedLine(a, b), DashedLine(a, d)
        ).set_color(LV)
        self.add(vg1,
                 CustomizedTex('A').next_to(a, DOWN),
                 CustomizedTex('B').next_to(b),
                 CustomizedTex('C').next_to(c, DOWN),
                 CustomizedTex('D').next_to(d, DOWN),
                 CustomizedTex('S').next_to(s, UP)
                 )
        # 2
        a_, b_, c_, s_ = [3.6, -0.5, 0], [2, 0, 0], [1, -1, 0], [2.2, 1.5, 0]
        vg2 = VGroup(
            DashedLine(a_, b_), DashedLine(b_, c_), CustomizedLine(a_, c_),
            CustomizedLine(s_, a_), DashedLine(s_, b_), CustomizedLine(s_, c_)
        ).set_color(JH)


class p5(ThreeDScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        # self.set_camera_orientation(phi=75 * DEGREES, theta=-90 * DEGREES)
        # 1
        tt=2
        a, b = [-2.6+tt, 0, 0], [-0.5+tt, 0, 0]
        c, d = b + DL, a + DL
        s = a + UP * 1.3 + RIGHT * 0.5
        vg1 = VGroup(
            CustomizedLine(s, d), CustomizedLine(s, c), CustomizedLine(s, b),
            CustomizedLine(b, c), CustomizedLine(c, d),
            DashedLine(s, a),
            DashedLine(a, b), DashedLine(a, d)
        ).set_color(LV)
        self.add(vg1,
                 CustomizedTex('A').next_to(a, DOWN),
                 CustomizedTex('B').next_to(b),
                 CustomizedTex('C').next_to(c, DOWN),
                 CustomizedTex('D').next_to(d, DOWN),
                 CustomizedTex('S').next_to(s, UP)
                 )
        # 2
        a_, b_, c_, s_ = [3.6, -0.5, 0], [2, 0, 0], [1, -1, 0], [2.2, 1.5, 0]
        vg2 = VGroup(
            DashedLine(a_, b_), DashedLine(b_, c_), CustomizedLine(a_, c_),
            CustomizedLine(s_, a_), DashedLine(s_, b_), CustomizedLine(s_, c_)
        ).set_color(JH)
        # p2
        m = (s + b) / 2
        self.add(DashedLine(a, m).set_color(BLACK), CustomizedLine(c, m),
                 CustomizedTex('M').next_to(m, UR)
                 )
        n = (np.array(s_) + np.array(b_)) / 2

